package com.ayu.scalalearn.chapter06

/**
  * @Author 徐林玉
  * @Description Test05Inherit
  * @Date 2022/7/28 17:01
  * @Version 1.0
  */
object Test05Inherit {

  //继承和java是类似的
  def main(args: Array[String]): Unit = {

    val stu1 = new Student7("ayu", 18)

    val stu2 = new Student7("yy", 15, "222222")


  }

}


class Person2 {


  var name: String = _
  var age: Int = _

  println("1、调用父类的主构造器")

  def this(name: String, age: Int) {
    this()
    this.name = name
    this.age = age
    println("2、调用父类的辅助构造器")
  }
}


class Student7(name: String, age: Int) extends Person2(name: String, age: Int) {


  var cardNo: String = _

  println("3、调用子类的主构造器")

  def this(name: String, age: Int, cardNo: String) {

    this(name, age)

    this.cardNo = cardNo

    println("4、调用子类的辅助构造器")
  }
}
